home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Thread Manager / Sample Applications / 68k Examples / Single Intersection Threads / UDocument.p < prev    next >
Encoding:
Text File  |  1994-11-17  |  19.1 KB  |  531 lines  |  [TEXT/MPS ]

  1. {–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  2.  
  3.     PROJECT:        Threads Traffic Simulation
  4.     
  5.     FILE:            UDocument.p
  6.     
  7.     LANGUAGE:        MPW Pascal (version 3.2)
  8.         
  9.     DESCRIPTION:    All handling of document manipulation is done here.  With this current
  10.                     document structure it should be easy to modify the program to support
  11.                     multiple documents at the same time.
  12.         
  13.     AUTHOR(S):        William H. Knott
  14.                     Apple Computer
  15.                     Cupertino, CA  95014
  16.                     AppleLink : KNOTT
  17.     
  18.     VERSION(S):        1.0        14-Aug-92    WHK    Brand New Today.
  19.  
  20. –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––}
  21.  
  22. UNIT UDocument;
  23.  
  24. INTERFACE
  25.  
  26. USES
  27.     MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, Traps,
  28.     
  29.     Threads, 
  30.     
  31.     UApplication, USimulation, UEventMgmt;
  32.  
  33.  
  34. PROCEDURE Segment_UDocument;
  35. PROCEDURE InitDocumentGlobals;
  36. PROCEDURE CreateNewDocument;
  37. PROCEDURE CloseDocument(theWindow    : WindowPtr);
  38. PROCEDURE CloseAllOpenDocuments;
  39. PROCEDURE HandleDocumentEvent(theWindow    : WindowPtr; theEvent    : EventRecord);
  40. FUNCTION IsWindowADocument(theWind    : WindowPtr)    : BOOLEAN;
  41. PROCEDURE DoPrintDocument(theWind    : WindowPtr);
  42. PROCEDURE DoPageSetupDoc(theWind    : WindowPtr);
  43.  
  44. TYPE
  45.     DocumentHdl        = ^DocumentPtr;        { This structure is provided in support of a multiple document        }
  46.     DocumentPtr        = ^DocumentRec;        { application.  By bundling the documents global variable             }
  47.     DocumentRec        = RECORD            { it is easy to convert this program into a multiple doc app.        }
  48.         docWindow    : WindowPtr;
  49.         docHasData    : BOOLEAN;            { Lets us know whether the document has any data at all.                                    }
  50.         docIsDirty    : BOOLEAN;            { If data in doc has changed, this lets us know whether we need to save the document.        }
  51.         docHasName    : BOOLEAN;            { If the user has saved once or open a saved file, doc will have a name, else 'Untitled'    }
  52.         docName        : Str32;            { The name of the currently open document.  Empty string means default.                        }
  53.     END;
  54.     
  55. VAR
  56.     gDocument        : DocumentHdl;
  57.     gWindowSize        : RECT;
  58.     
  59. IMPLEMENTATION
  60.  
  61. {$S Document}
  62. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  63. {                                                                                      }
  64. {    Segment_UDocument                                                                  }
  65. {                                                                                      }
  66. {    Provided as a convenient way of unloading the UDocument segment when needed          }
  67. {                                                                                      }
  68. {    July 15, 1992        WHK        Created today                                          }
  69. {                                                                                      }
  70. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  71. PROCEDURE Segment_UDocument;
  72.     BEGIN
  73.     END;
  74.     
  75. {$S Document}
  76. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  77. {                                                                                      }
  78. {    InitDocumentGlobals                                                                  }
  79. {                                                                                      }
  80. {    Initialize any variables used by document management when the application starts. }
  81. {                                                                                      }
  82. {    July 15, 1992        WHK        Created today                                          }
  83. {                                                                                      }
  84. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  85. PROCEDURE InitDocumentGlobals;
  86.     BEGIN
  87.         gDocument := NIL;
  88.     END;
  89.  
  90. {$S Document}
  91. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  92. {                                                                                      }
  93. {    CreateADocument                                                                      }
  94. {                                                                                      }
  95. {    Generates a new document and initializes a new traffic light into it.                }
  96. {                                                                                      }
  97. {    July 15, 1992        WHK        Created today                                          }
  98. {                                                                                      }
  99. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  100. FUNCTION CreateADocument(docName    : Str255;
  101.                             windSize    : RECT)    : DocumentHdl;
  102.     VAR
  103.         buildDocument    : DocumentHdl;
  104.         tempWind        : WindowPtr;
  105.     BEGIN
  106.         CreateADocument := NIL;
  107.         buildDocument := DocumentHdl(NewHandle(Sizeof(DocumentRec)));
  108.         IF (buildDocument = NIL)THEN EXIT(CreateADocument);
  109.  
  110.         tempWind := GetNewWindow(kNewWindow,NIL,pointer(-1));
  111.         IF (tempWind = NIL)THEN
  112.             BEGIN
  113.                 DisposHandle(Handle(buildDocument));
  114.                 EXIT(CreateADocument);
  115.             END;
  116.             
  117.         IF docName <> '' THEN
  118.             SetWTitle(tempWind, docName);
  119.             
  120.         SizeWindow(tempWind,(windSize.right - windSize.left), (windSize.bottom - windSize.top),TRUE);
  121.         MoveWindow(tempWind,windSize.left,windSize.top,TRUE);
  122.         ShowWindow(tempWind);
  123.                         
  124.         buildDocument^^.docWindow := tempWind;
  125.         CreateADocument := buildDocument;
  126.         
  127.         gWindowSize := tempWind^.portRect;
  128.         
  129.         gIntoCooperativeWind := tempWind;
  130.         
  131.         InitializeRoadParams;
  132.         
  133.         CreateTrafficLight;
  134.     END;
  135.  
  136. {$S Document}
  137. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  138. {                                                                                      }
  139. {    CreateNewDocument                                                                  }
  140. {                                                                                      }
  141. {    The user had chosen the New command from the File menu, which means  that we now  }
  142. {    want to create a new document.  The current documentation structure for this      }
  143. {    application only allows for one open document at a time, so there should not be   }
  144. {    an already open document window when this routine is called.                      }
  145. {                                                                                      }
  146. {    July 15, 1992        WHK        Created today                                          }
  147. {                                                                                      }
  148. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  149. PROCEDURE CreateNewDocument;
  150.     VAR
  151.         windSize    : RECT;
  152.     BEGIN
  153.         IF (gDocument <> NIL)THEN EXIT(CreateNewDocument);
  154.         
  155.         windSize := ScreenBits.bounds;
  156.         InsetRect(windSize,5,5);
  157.         windSize.top := windSize.top + 40;
  158.  
  159.         gDocument := CreateADocument('Threaded Traffic Simulation', windSize);
  160.         IF (gDocument = NIL)THEN EXIT(CreateNewDocument);
  161.         ShowWindow(gDocument^^.docWindow);
  162.         
  163.         SetMenuBarState;
  164.     END;
  165.  
  166. {$S Document}
  167. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  168. {                                                                                      }
  169. {    CloseDocument                                                                      }
  170. {                                                                                      }
  171. {    The user had chosen the Close command from the File menu, click in the windows      }
  172. {    close box, or Quit the application.  It is here that we close the document,          }
  173. {    prompting the user to save changes.  If the user selects cancel to any of these      }
  174. {    options, we need to set the global variable gDone back to FALSE.                  }
  175. {                                                                                      }
  176. {    July 15, 1992        WHK        Created today                                          }
  177. {                                                                                      }
  178. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  179. PROCEDURE CloseDocument(theWindow    : WindowPtr);
  180.     BEGIN
  181.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(CloseDocument);
  182.         
  183.         DisposeWindow(gDocument^^.docWindow);
  184.         
  185.         DisposHandle(Handle(gDocument));
  186.         gDocument := NIL;
  187.  
  188.         SetMenuBarState;
  189.     END;
  190.  
  191. {$S Document}
  192. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  193. {                                                                                      }
  194. {    CloseAllOpenDocuments                                                              }
  195. {                                                                                      }
  196. {    Currently does nothing beyond calling CloseDocument, but is here for support of a }
  197. {    multiple document enviroment.                                                      }
  198. {                                                                                      }
  199. {    July 15, 1992        WHK        Created today                                          }
  200. {                                                                                      }
  201. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  202. PROCEDURE CloseAllOpenDocuments;
  203.     BEGIN
  204.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(CloseAllOpenDocuments);
  205.         CloseDocument(gDocument^^.docWindow);
  206.     END;
  207.     
  208. {$S Document}
  209. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  210. {                                                                                      }
  211. {    InvalDocumentScrollBars                                                              }
  212. {                                                                                      }
  213. {    This makes an assumption that the window being passed to it has two scroll bars,  }
  214. {    one along the right hand side and the other along the bottom.  It invalidates      }
  215. {    the area which the scroll bars occupy.                                              }
  216. {                                                                                      }
  217. {    July 15, 1992        WHK        Created today                                          }
  218. {                                                                                      }
  219. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  220. PROCEDURE InvalDocumentScrollBars(theWindow    : WindowPtr);
  221.     VAR
  222.         ScrollRect    : RECT;
  223.     BEGIN
  224.         ScrollRect := theWindow^.portRect;
  225.         ScrollRect.top := ScrollRect.bottom - 15;
  226.         InvalRect(ScrollRect);
  227.         ScrollRect := theWindow^.portRect;
  228.         ScrollRect.left := ScrollRect.right - 15;
  229.         InvalRect(ScrollRect);
  230.     END;
  231.  
  232. {$S Document}
  233. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  234. {                                                                                      }
  235. {    HandleDocumentGrow                                                                  }
  236. {                                                                                      }
  237. {    Currently the user is moused down in the grow region of your window and the          }
  238. {    window is front most.  The standard GrowWindow toolbox routine is called.  If      }
  239. {    the window is resized then the windows scrollbars need to be invalidated.          }
  240. {                                                                                      }
  241. {    July 15, 1992        WHK        Created today                                          }
  242. {                                                                                      }
  243. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  244. PROCEDURE HandleDocumentGrow(theWindow    : WindowPtr;
  245.                             downWhere    : POINT);
  246.     VAR
  247.         windRect    : RECT;
  248.         sizing        : LONGINT;
  249.         holdPort    : GrafPtr;
  250.     BEGIN
  251.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(HandleDocumentGrow);
  252.  
  253.         GetPort(holdPort);
  254.         SetPort(gDocument^^.docWindow);
  255.         SetRect(windRect,200,100,MaxInt, MaxInt);
  256.         sizing := GrowWindow(gDocument^^.docWindow,downWhere, windRect);
  257.         IF sizing > 0 THEN
  258.             BEGIN
  259.                 InvalDocumentScrollBars(gDocument^^.docWindow);
  260.                 SizeWindow(gDocument^^.docWindow,LoWord(sizing),HiWord(sizing),TRUE);
  261.                 InvalDocumentScrollBars(gDocument^^.docWindow);
  262.             END;
  263.         SetPort(holdPort);
  264.     END;
  265.     
  266. {$S Document}
  267. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  268. {                                                                                      }
  269. {    HandleDocumentMousedown                                                              }
  270. {                                                                                      }
  271. {    A mousedown occurred in the document.  First we need to see if the document is      }
  272. {    frontmost. If it isn't. lets bring it to the front.  If it is, handle what is      }
  273. {    approprate for a mousedown.                                                          }
  274. {                                                                                      }
  275. {    July 15, 1992        WHK        Created today                                          }
  276. {                                                                                      }
  277. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  278. PROCEDURE HandleDocumentMousedown(theWindow    : WindowPtr;
  279.                                 theEvent    : EventRecord);
  280.     VAR
  281.         where     : INTEGER;
  282.     BEGIN
  283.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(HandleDocumentMousedown);
  284.  
  285.         where := FindWindow(theEvent.where,theWindow);
  286.     END;
  287.  
  288. {$S Document}
  289. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  290. {                                                                                      }
  291. {    HandleDocumentKeydown                                                              }
  292. {                                                                                      }
  293. {    A keydown occured when this documents window was frontmost.  This document           }
  294. {    structure has no need for keydowns, so this routine does nothing.                  }
  295. {                                                                                      }
  296. {    July 15, 1992        WHK        Created today                                          }
  297. {                                                                                      }
  298. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  299. PROCEDURE HandleDocumentKeydown(theWindow    : WindowPtr; 
  300.                                         theKey        : Char);
  301.     BEGIN
  302.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(HandleDocumentKeydown);
  303.  
  304.     END;
  305.  
  306. {$S Document}
  307. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  308. {                                                                                      }
  309. {    DrawTheRoad                                                                          }
  310. {                                                                                      }
  311. {    We need to draw the intersection world as we know it, two roads, four turn          }
  312. {    lanes, and four big patches of green with all the ammenities.  Nuff said.          }
  313. {                                                                                      }
  314. {    July 15, 1992        WHK        Created today                                          }
  315. {                                                                                      }
  316. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  317. PROCEDURE DrawTheRoad;
  318.     VAR
  319.         holdColor        : RGBColor;
  320.         workColor        : RGBColor;
  321.         tempRect        : RECT;
  322.     BEGIN
  323.         Pensize(2,2);
  324.         ForeColor(WhiteColor);
  325.         Moveto(gHRoadLeft, gHRoadTop);        { First the edges of the road!    }
  326.         Lineto(gVRoadLeft, gHRoadTop);
  327.         Lineto(gVRoadLeft, gVRoadTop);
  328.         
  329.         Moveto(gVRoadRight, gVRoadTop);
  330.         Lineto(gVRoadRight, gHRoadTop);
  331.         Lineto(gHRoadRight, gHRoadTop);
  332.         
  333.         Moveto(gHRoadRight, gHRoadBottom);
  334.         Lineto(gVRoadRight, gHRoadBottom);
  335.         Lineto(gVRoadRight, gVRoadBottom);
  336.         
  337.         Moveto(gVRoadLeft, gVRoadBottom);
  338.         Lineto(gVRoadLeft, gHRoadBottom);
  339.         Lineto(gHRoadLeft, gHRoadBottom);
  340.         
  341.         ForeColor(GreenColor);        { Then the grassy corners    }
  342.         SetRect(tempRect, gHRoadLeft, gVRoadTop, gVRoadLeft - 2, gHRoadTop);
  343.         PaintRect(tempRect);
  344.         SetRect(tempRect, gVRoadRight + 2, gVRoadTop,gHRoadRight , gHRoadTop);
  345.         PaintRect(tempRect);
  346.         SetRect(tempRect, gHRoadLeft,gHRoadBottom + 2 , gVRoadLeft - 2, gVRoadBottom);
  347.         PaintRect(tempRect);
  348.         SetRect(tempRect, gVRoadRight + 2, gHRoadBottom + 2,gHRoadRight , gVRoadBottom);
  349.         PaintRect(tempRect);
  350.         
  351.         ForeColor(BlackColor);        { And the Road itself        }
  352.         SetRect(tempRect, gHRoadLeft, gHRoadTop + 2,gHRoadRight , gHRoadBottom);
  353.         FillRect(tempRect, gray);
  354.         SetRect(tempRect, gVRoadLeft, gVRoadTop,gVRoadRight , gVRoadBottom);
  355.         FillRect(tempRect, gray);
  356.  
  357.         ForeColor(YellowColor);        { And the lines near the turning lanes.        }
  358.         Moveto(gHRoadLeft, gHRoadTop + 20);
  359.         Lineto(gVRoadLeft, gHRoadTop + 20);
  360.         Moveto(gVRoadRight, gHRoadTop + 40);
  361.         Lineto(gHRoadRight, gHRoadTop + 40);
  362.         Moveto(gVRoadLeft + 40, gVRoadTop);
  363.         Lineto(gVRoadLeft + 40, gHRoadTop);
  364.         Moveto(gVRoadLeft + 20, gVRoadBottom);
  365.         Lineto(gVRoadLeft + 20, gHRoadBottom);
  366.  
  367.         ForeColor(WhiteColor);        { Now the concrete medians in the Road.    }
  368.         SetRect(tempRect, gHRoadLeft - 5, gHRoadTop + 20 , gVRoadLeft - 80, gHRoadBottom - 20);
  369.         PaintRoundRect(tempRect, 10, 10);
  370.         SetRect(tempRect, gVRoadRight + 80, gHRoadTop + 20 , gHRoadRight + 5, gHRoadBottom - 20);
  371.         PaintRoundRect(tempRect, 10, 10);
  372.         SetRect(tempRect, gVRoadLeft + 20, gVRoadTop -5 , gVRoadRight - 20, gHRoadTop - 80);
  373.         PaintRoundRect(tempRect, 10, 10);
  374.         SetRect(tempRect, gVRoadLeft + 20, gHRoadBottom + 80 , gVRoadRight - 20, gVRoadBottom + 5);
  375.         PaintRoundRect(tempRect, 10, 10);
  376.  
  377.         ForeColor(BlackColor);        { Now the concrete medians in the Road.    }
  378.         DrawTheTraficLight(FALSE);
  379.     END;
  380.     
  381. {$S Document}
  382. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  383. {                                                                                      }
  384. {    HandleDocumentUpdate                                                              }
  385. {                                                                                      }
  386. {    The window needs to be updated.  Currently the window has no content, with the       }
  387. {    exception of scroll bars and a grow icon, so they are drawn.                      }
  388. {                                                                                      }
  389. {    July 15, 1992        WHK        Created today                                          }
  390. {                                                                                      }
  391. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  392. PROCEDURE HandleDocumentUpdate(theWindow    : WindowPtr);
  393.     VAR
  394.         holdPort    : GrafPtr;
  395.         
  396.     BEGIN
  397.         GetPort(holdPort);
  398.         SetPort(gDocument^^.docWindow);
  399.         BeginUpdate(gDocument^^.docWindow);
  400.         
  401.         EraseRect(gDocument^^.docWindow^.portRect);
  402.         
  403.         DrawTheRoad;
  404.         UpdateAllCars;
  405.         
  406.         EndUpdate(gDocument^^.docWindow);
  407.         SetPort(holdPort);
  408.     END;
  409.  
  410. {$S Document}
  411. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  412. {                                                                                      }
  413. {     HandleDocumentActivateEvt                                                          }
  414. {                                                                                      }
  415. {    The document window was either activated or deactivated.  We need to determine       }
  416. {    which and handle the window appearence approprately                                  }
  417. {                                                                                      }
  418. {    July 15, 1992        WHK        Created today                                          }
  419. {                                                                                      }
  420. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  421. PROCEDURE HandleDocumentActivateEvt(theWindow    : WindowPtr; theEvent    : EventRecord);
  422.     VAR
  423.         activating        : BOOLEAN;
  424.         theGrowRect    : RECT;
  425.     BEGIN
  426.         SetPort(theWindow);
  427.         activating := (BAnd(theEvent.modifiers, activeFlag) <> 0);
  428.         theGrowRect := theWindow^.portRect;
  429.         theGrowRect.left := theGrowRect.right - 14;
  430.         theGrowRect.top := theGrowRect.bottom - 14;
  431.         InvalRect(theGrowRect);
  432.     END;
  433.  
  434. {$S Document}
  435. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  436. {                                                                                      }
  437. {    HandleDocumentApp4Event                                                              }
  438. {                                                                                      }
  439. {    The application has experienced a context switch.  If anything special is needed  }
  440. {    to be done to the front document, now would be a good time.                          }
  441. {                                                                                      }
  442. {    July 15, 1992        WHK        Created today                                          }
  443. {                                                                                      }
  444. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  445. PROCEDURE HandleDocumentApp4Event(theWindow    : WindowPtr; theEvent    : EventRecord);
  446.     BEGIN
  447.     END;
  448.     
  449. {$S Document}
  450. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  451. {                                                                                      }
  452. {    HandleDocumentEvent                                                                  }
  453. {                                                                                      }
  454. {    If an event occurred, and it occurred to the document window, then the event      }
  455. {    will be routed through this procedure.                                              }
  456. {                                                                                      }
  457. {    July 15, 1992        WHK        Created today                                          }
  458. {                                                                                      }
  459. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  460. PROCEDURE HandleDocumentEvent(theWindow    : WindowPtr; theEvent    : EventRecord);
  461.     VAR
  462.         key        : Char;
  463.     BEGIN
  464.         IF theWindow = NIL THEN EXIT(HandleDocumentEvent);
  465.         
  466.         CASE theEvent.what OF
  467.             mouseDown:        HandleDocumentMousedown(theWindow, theEvent);
  468.             keyDown, autoKey:
  469.                 BEGIN
  470.                     key := CHR(BAnd(theEvent.message, charCodeMask));
  471.                     HandleDocumentKeydown(theWindow, key);
  472.                 END;
  473.             UpdateEvt:        HandleDocumentUpdate(theWindow);
  474.             ActivateEvt:    HandleDocumentActivateEvt(theWindow, theEvent);
  475.             App4Evt:        HandleDocumentApp4Event(theWindow, theEvent);
  476.             OTHERWISE
  477.                 ;    
  478.         END;
  479.     END;
  480.     
  481. {$S Document}
  482. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  483. {                                                                                      }
  484. {    IsWindowADocument                                                                  }
  485. {                                                                                      }
  486. {    Given a window pointer, this routine reports when the window is a document.  The  }
  487. {    reason for handling window verification this way is to add flexibility so that    }
  488. {    this application can support multple documents in the future.                      }
  489. {                                                                                      }
  490. {    July 15, 1992        WHK        Created today                                          }
  491. {                                                                                      }
  492. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  493. FUNCTION IsWindowADocument(theWind    : WindowPtr)    : BOOLEAN;
  494.     BEGIN
  495.         IsWindowADocument := FALSE;
  496.         IF ((gDocument = NIL) | (gDocument^^.docWindow = NIL))THEN EXIT(IsWindowADocument);
  497.         
  498.         IsWindowADocument := (theWind = gDocument^^.docWindow);
  499.     END;
  500.     
  501. {$S Document}
  502. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  503. {                                                                                      }
  504. {    DoPrintDocument                                                                      }
  505. {                                                                                      }
  506. {    Given a window pointer,find the document that is associated with it and print it. }
  507. {                                                                                      }
  508. {    July 15, 1992        WHK        Created today                                          }
  509. {                                                                                      }
  510. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  511. PROCEDURE DoPrintDocument(theWind    : WindowPtr);
  512.     BEGIN
  513.         { I have not yet implemented document printing yet! - WHK    }
  514.     END;
  515.  
  516. {$S Document}
  517. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  518. {                                                                                      }
  519. {    DoPrintDocument                                                                       }
  520. {                                                                                      }
  521. {    Given a window pointer, find the document that is associated with it and print it }
  522. {                                                                                      }
  523. {    July 15, 1992        WHK        Created today                                          }
  524. {                                                                                      }
  525. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  526. PROCEDURE DoPageSetupDoc(theWind    : WindowPtr);
  527.     BEGIN
  528.         { I have not yet implemented document printing yet! - WHK    }
  529.     END;
  530.  
  531. END.